# Contributor: Ben Pye <ben@curlybracket.co.uk>
# Maintainer: Ben Pye <ben@curlybracket.co.uk>
pkgname=libunwind
pkgver=1.6.2
pkgrel=0
pkgdesc="Portable and efficient C programming interface (API) to determine the call-chain of a program"
url="https://www.nongnu.org/libunwind/"
arch="all"
license="MIT"
options="!check" # v1.4.0 12 tests failing - https://github.com/libunwind/libunwind/issues/164
depends_dev="libucontext-dev"
makedepends_build="autoconf automake libtool"
makedepends_host="$depends_dev linux-headers xz-dev"
makedepends="$makedepends_build $makedepends_host"
subpackages="$pkgname-dbg $pkgname-static $pkgname-dev $pkgname-doc"
source="https://download.savannah.gnu.org/releases/libunwind/libunwind-$pkgver.tar.gz
	force-enable-man.patch
	musl-mips-fix.patch
	ppc64-musl.patch
	fix-libunwind-pc-in.patch
	"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	LDFLAGS="$LDFLAGS -lucontext" CFLAGS="$CFLAGS -fno-stack-protector" \
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-cxx-exceptions
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
1d17dfb14f99a894a6cda256caf9ec481c14068aaf8f3a85fa3befa7c7cca7fca0f544a91a3a7c2f2fc55bab19b06a67ca79f55ac9081151d94478c7f611f8f7  libunwind-1.6.2.tar.gz
de3cefd8a2fa9ae3eabf052cb94a1fdde4f9b7e85af839220592269f7a885470572f67ecf6d773129de8d82916fbcbdda44b541f4eeec84744c54f230c36b6a1  force-enable-man.patch
a1751b80f2c42a741f0a7778f758c7afe42653bf61a353edf38182d731008ed7bd0b8a41bf466aa83275b22241bfcd4f6051055489e3cc87fcd7dd4488bc089d  musl-mips-fix.patch
3b59620c758784faa6d66c8a0a2e49ced743b7ebff6a7e461e40aea653ef9f8cbd8948fb766c63acdd625cb506601c102f133074cef9ef150e9bb8b81584fe9d  ppc64-musl.patch
52b568846db7adb50a181f17635e53c8a6d99d6d13c3d35fd8c9a5de5ec0a1ad18d8462c4ae4483d413d4b5aa7375017c36b5cb49805b6f67d96cffafbd02548  fix-libunwind-pc-in.patch
"
